package Easy;

import java.util.Arrays;

public class Solution88 {
    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        for (int k = 0; k < n; k++, m++)
            nums1[m] = nums2[k];
//        Arrays.sort(nums1);
        quickSort(nums1,0,nums1.length-1);
    }
    public static void quickSort(int[] arr,int left,int right){
        int i = left;
        int j = right;

        if(i>j)
            return;
        int temp=arr[i];
        while (i<j){
            while (i<j&&arr[j]>=temp)
                j--;
            while (i<j&&arr[i]<=temp)
                i++;
            if (i<j) {
                int t = arr[j];
                arr[j] = arr[i];
                arr[i] = t;
                j--;
            }
        }
        arr[left]=arr[i];
        arr[i]=temp;
        quickSort(arr,left,i-1);
        quickSort(arr,i+1,right);
    }

    public static void main(String[] args) {
        int[] arr1 = new int[]{1, 2, 3, 0, 0, 0};
        int[] arr2 = new int[]{2,5,6};
        merge(arr1,3,arr2,3);
        for(int p:arr1){
            System.out.print(p+" ");
        }
    }

}
